from base.base import Base
from page import y_order_element as data


class PageOrder(Base):
    def __init__(self, url):
        super().__init__(url)

    # 点击订单管理主菜单
    def click_a(self):
        self.click(data.order_a)

    # 点击订单管理子菜单
    def click_manager(self):
        self.click(data.order_manager)

    # 进入iframe界面
    def to_iframe(self):
        self.go_iframe(data.iframe_id)

    # 点击搜索按钮
    def click_search(self):
        self.click(data.butt_search)

    # 点击重置按钮
    def click_reset_search(self):
        self.click(data.butt_search_reset)

    # 输入订单号
    def input_order_id(self, id):
        self.input(data.input_order_id, id)

    # 输入用户信息
    def input_user_info(self, info):
        self.input(data.input_user_name, info)

    # 选择订单状态
    def select_order_state(self, num):
        self.click(data.select_order_state)
        self.click(data.order_state(num))

    # 选择支付状态
    def select_pay_state(self, num):
        self.click(data.select_pay_state)
        self.click(data.pay_state(num))

    # 设置总价（最大值、最小值）
    def input_money(self, min_money, max_money):
        self.input(data.input_min_money, min_money)
        self.input(data.input_max_money, max_money)

    # 设置支付金额（最大值、最小值）
    def input_pay(self, min_pay, max_pay):
        self.input(data.input_min_pay, min_pay)
        self.input(data.input_max_pay, max_pay)

    # 设置单价（最大值、最小值）
    def input_price(self, min_price, max_price):
        self.input(data.input_min_price, min_price)
        self.input(data.input_max_price, max_price)

    # 选择出货仓库
    def select_out_warehouse(self):
        self.click(data.select_out_warehouse)
        self.click(data.out_warehouse)

    # 选择订单模式
    def select_order_schema(self, num):
        self.click(data.select_order_schema)
        self.click(data.order_schema(num))

    # 选择来源
    def select_source(self, num):
        self.click(data.select_source)
        self.click(data.source_web(num))

    # 设置地址信息
    def input_address(self, value):
        self.input(data.input_address_info, value)

    # 点击订单售后子菜单
    def click_after(self):
        self.click(data.order_after)

    # 输入售后原因
    def input_after_cause(self, value):
        self.input(data.input_after_cause, value)

    # 选择退款类型
    def select_refund_type(self, num):
        self.click(data.select_refund_type)
        self.click(data.refund_type(num))

    # 输入退款说明
    def input_refund_explain(self, value):
        self.input(data.input_refund_explain, value)

    # 输入快递公司
    def input_courier_services(self, value):
        self.input(data.input_courier_services, value)

    # 输入快递单号
    def input_courier_number(self, value):
        self.input(data.input_courier_number, value)

    # 整合订单管理搜索方法
    def order_manager_search(self, order_id, info, order_state, pay_state, money, pay, price, schema, source, address):
        self.input_order_id(order_id)
        self.input_user_info(info)
        self.select_order_state(order_state)
        self.select_pay_state(pay_state)
        self.input_money(*money)
        self.input_pay(*pay)
        self.input_price(*price)
        self.select_out_warehouse()
        self.select_order_schema(schema)
        self.select_source(source)
        self.input_address(address)
        self.click_search()

    # 整合订单售后搜索方法
    def order_after_search(self, order_id, info, order_state, pay_state, cause, pay, price, refund_explain, refund_type,
                           courier_services,
                           courier_number):
        self.input_order_id(order_id)
        self.input_user_info(info)
        self.select_order_state(order_state)
        self.select_pay_state(pay_state)
        self.input_after_cause(cause)
        self.input_pay(*pay)
        self.input_price(*price)
        self.input_refund_explain(refund_explain)
        self.input_courier_services(courier_services)
        self.select_refund_type(refund_type)
        self.input_courier_number(courier_number)
        self.click_search()


